<?php
session_start();
if(empty($_SESSION['auth_username']) && empty($_SESSION['auth_password']))
{
header('Location: ../index.php');
} else if ($_SESSION['auth_level'] == 1)
{
header('Location: ../index.php');
}
include_once '../class_projekt.php';
$projekt = new Projekt;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>XML einlesen</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<div id="admin_function">
<h1>XML einlesen </h1>
<a href="admin.php"> Zur&uuml;ck zum Admincenter </a>
   <form action="xml.php" method="post" enctype="multipart/form-data">
   <p>Bitte laden Sie ihre XML - Datei hoch!<br>
   <select name="proj">
   <?php $projekt->pros(); ?>
   </select>
   <select name="lang">
  <?php $projekt->lang(); ?>
 </select>
    <input name="datei" type="file" size="50" maxlength="100000" accept="text/*">
  </p>
  <input type="submit" name="absenden" value="Hochladen">
</form>


<?php
//INCLUDE
//XML CLASS
//OPTION
$absenden = $_POST['absenden'];

include 'class_xml.php';
$xml = new xml();

if ($absenden)
{
$lang = $_POST['lang'];
$proj = $_POST['proj'];

$uploaddir = 'upload/';


$ende = $_FILES['datei']['type'];
if ($ende == 'text/xml')
{
if (move_uploaded_file($_FILES['datei']['tmp_name'], $uploaddir . $_FILES['datei']['name'])) {
echo "XML hochgeladen";

echo "<br/>"; 
$xml->auslesen();
} 
$xml->dbarray();
$xml->marray();

?>
<form action="xml.php" method="POST">
Diese Felder sind noch nicht in der Datenbank!<br/>
<?php
$xml->newType();
$_SESSION['xml_attri'] = $xml->xml_attri;
$_SESSION['xml_array'] =  $xml->xml_array;

?>
<input type="hidden" value="<?php echo $lang; ?>" name="lang">
<input type="hidden" value="<?php echo $proj; ?>" name="proj">
<input type="submit" value="Hinzuf&uuml;gen" name="submit">
</form>
<?php
}else {
echo "Kein XML - Typ!";
}
}

?>

<?php
if ($_POST['submit'])
{
 $lang = $_POST['lang'];
 $proj = $_POST['proj'];
 $type = $_POST['type'];
 
 $xml->insertType($type); 
 ?><form action="xml.php" method="post">
 Sollen die W&ouml;rter auch geladen werden?
 
 
 <select name="wort">
      <option value="1">Ja</option>
      <option value="2">Nein</option>
 </select>
 <input type="hidden" value="<?php echo $lang; ?>" name="lang">
 <input type="hidden" value="<?php echo $proj; ?>" name="proj">
 <input type="submit" name="word" value="Absenden">
 </form>
 <?
}

if ($_POST['word'])
{
 $lang = $_POST['lang'];
 $proj = $_POST['proj'];
if ($_POST['wort'] == 1)
 {
 $xml->setArrays($_SESSION['xml_attri'],$_SESSION['xml_array']);
 $xml->dbarray();
 $xml->findWords($lang,$proj);
 } else {
 }
 
 }
?>
</div>
</body>
</html>
